<?php
/**
 * Icons
 * @author Erko Risthein <erko@risthein.ee>
 * @copyright Copyright (C) 2009 Erko Risthein
 * @link http://erko.risthein.ee/decode/
 * @license http://www.gnu.org/licenses/ GNU General Public License
 * @package decode_explorer
 */
class Icons {	
	private static $icons = array(
		'acrobat'	=>	array('pdf'),
		'application'	=>	array('exe'),
		'cd'		=>	array('iso'),
		'code_blue' 	=>	array('css', 'js', 'sql', 'xml', 'phps'),
		'code_red'	=>	array('java', 'class', 'cpp'),
		'compressed'	=>	array('zip', 'rar', 'ace', 'gz', 'tar', '7z'),
		'excel'		=>	array('xls', 'ods', 'xlsx'),
		'film'		=>	array('avi', 'mpg', 'mpeg', 'mov', 'wmv', 'swf', 'asf'),
		'image'		=>	array('jpg', 'jpeg', 'gif', 'png', 'bmp', 'ico'),
		'powerpoint'	=>	array('ppt', 'odp', 'pptx'),
		'sound'		=>	array('mp3', 'wma', 'mid', 'midi', 'ogg', 'wav', 'ape', 'flac'),
		'text'		=>	array('txt', 'nfo'),
		'word'		=>	array('doc', 'rtf', 'odt', 'docx'),
		'world'		=>	array('html', 'htm', 'xhtml', 'tpl', 'xml'),
		'world_link'	=>	array('php', 'php3', 'asp', 'jsp'),
	);
	
	/**
	 * Gets the file icon according to the extension
	 * @param string $extension the file extension
	 * @return string icon file name
	 */
	public static function get($extension) {
		foreach (self::$icons as $icon => $extensions) {
			if (in_array($extension, $extensions)) {
				return $icon . '.png';
				break;
			}
		}
		return 'blank.png';
	}
}
?>